import sys
import traceback
import logging

from PyQt5.QtWidgets import QApplication


def qt5_program_run(AnyVacClass, logging_level=logging.WARNING, *args):
    logging.basicConfig(level=logging_level,  # filename="test.log",
                        format="----%(levelname)s----  %(message)s")

    try:
        app = QApplication(sys.argv)

        mainwin = AnyVacClass(*args)
        mainwin.show()

        sys.exit(app.exec_())
    except Exception as e:
        logging.error("frw.entry::qt5_program_run() -->> {}".format(e))
        if logging_level <= logging.INFO:
            traceback.print_exc()
        sys.exit(-1)
